package com.donzell.web.controller.admin;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.donzell.dao.AdminUserDao;
import com.donzell.dao.RoleDao;
import com.donzell.joinmodel.AdminUser;
import com.donzell.model.EcsRole;

@Controller
@RequestMapping("/admin")
public class AdminController {
	@Autowired
	private AdminUserDao adminUserDao;
	
	@Autowired
	private RoleDao roleDao;
	
	@RequestMapping("/tologin")
	public String toLoginView(){
		return "/admin/login";
	}
	@RequestMapping("/tomain")
	public String toMainView(){ 
		return "/admin/index";
	}
	
	@RequestMapping("/toadminlist")
	public String toAdminList(ModelMap model){
		List<AdminUser> adminUserList = adminUserDao.getAllUsers();
		model.put("adminList", adminUserList);
		return "/admin/admin-list";
	}
	
	@RequestMapping("/torolelist")
	public String toRoleList(ModelMap model){
		List<EcsRole> adminRoleList = roleDao.findAll();
		model.put("roleList", adminRoleList);
		return "/admin/admin-role";
	}
	

	

	
}
